package com.shrct.businessprocess.project.impl;

import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.project.RCSalesAssignment;
import com.shrct.businessprocess.project.RCSalesAssignmentCriteria;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import org.hibernate.Query;

public class RCSalesAssignmentCriteriaImpl extends HQLBasedPagedQueryCriteria<RCSalesAssignment> implements RCSalesAssignmentCriteria {
  private RCEmployee saler;
  
  public RCEmployee getSaler() {
    return this.saler;
  }
  
  public RCSalesAssignmentCriteria setSaler(final RCEmployee saler) {
    this.saler = saler;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.project.impl.RCSalesAssignmentImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSaler()) ){
    	hql += " and ((this.saler) = (:saler))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    addOrder("this.startDate",edu.fudan.mylang.pf.query.OrderItem.ASC);
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSaler())){
    	query.setParameter("saler",getSaler()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCSalesAssignmentCriteriaImpl() {
    initOrderBys();
  }
}
